<?php
class CommentModel extends RelationModel {
	protected $_link = array(
		'User' => array(
			'mapping_type'	=> BELONGS_TO,
			'mapping_name'	=>'User',		//设置关联要查询的表
			'class_name'	=>'User',		//设置关联要查询的表
			'foreign_key'	=>'uid',		//设置外键
			'mapping_fields'=>'nickname,url',	//设置需要查询的列
			'as_fields'		=>'nickname,url',	//设置列的别名
		)
	);
	
	protected $_validate = array(
		array('pid','require','回复的报道不存在！'), //默认情况下用正则进行验证
		array('content','require','回复的内容不能为空！'), //默认情况下用正则进行验证
	);
	
	//获取文章相应的评论
	public function postAllComment($pid){
		return $this->where('pid='.intval($pid).' AND pid > 0 ')->select();
	}
}